﻿using System;
using System.ComponentModel.DataAnnotations;
using iHouse.Resource;
using System.ComponentModel.DataAnnotations.Schema;

namespace iHouse.Model.Data
{
    [MetadataType(typeof(Book_Validation))]
    [Table("Book")]
    public class Book
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Author { get; set; }
        public string Location { get; set; }
        public Nullable<System.DateTime> PublishDate { get; set; }
        public Nullable<int> Type { get; set; }
        public Nullable<int> CategoryID { get; set; }
        public Nullable<int> Language { get; set; }
        public string ImagePath { get; set; }
        public string ISBN10 { get; set; }
        public string ISBN13 { get; set; }
        public Nullable<int> PublisherID { get; set; }
        public Nullable<decimal> Score { get; set; }

        public virtual Category Category { get; set; }
        public virtual Publisher Publisher { get; set; }
    }

    public class Book_Validation
    {
        [Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "BookNameRequired")]
        [StringLength(250)]
        public string Name { get; set; }

        [StringLength(20, ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "BookISBNLength")]
        public string ISBN10 { get; set; }

        [StringLength(20, ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "BookISBNLength")]
        public string ISBN13 { get; set; }

        [DataType(DataType.DateTime)]
        public DateTime PublishDate { get; set; }

        [StringLength(200)]
        public string Author { get; set; }
    }
}
